#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QPushButton *pushbutton = new QPushButton(this);
    pushbutton->setText("按钮");

    //打印按钮的位置和尺寸
    QRect rect = pushbutton->geometry();
    qDebug() <<rect;

    //设置pushbutton的位置和尺寸
    rect.setWidth(600);
    rect.setHeight(200);
    rect.setX(100);
    rect.setY(100);
    pushbutton->setGeometry(rect);

    //创建一个图标对象
    QIcon icon(":/chicken.png");
    //设置按钮的图标
    pushbutton->setIcon(icon);
    //更改图标的大小
    pushbutton->setIconSize(QSize(50,50));
}

Widget::~Widget()
{
    delete ui;
}

